#pragma once

/* Status register flags */
#define SR_SIE		0x00000002 /* Supervisor Interrupt Enable */
#define SR_SPP		0x00000100 /* Previously Supervisor */
#define SR_SUM		0x00040000 /* Supervisor User Memory Access */

#define SR_FS		0x00006000 /* Floating-point Status */

#define SR_VS		0x00000600 /* Vector Status */

#define SR_FS_VS	(SR_FS | SR_VS) /* Vector and Floating-Point Unit */


#define CSR_SSTATUS		0x100
#define CSR_SIE			0x104
#define CSR_STVEC		0x105
#define CSR_SSCRATCH	0x140
#define CSR_SEPC		0x141
#define CSR_SCAUSE		0x142
#define CSR_STVAL		0x143
#define CSR_SIP			0x144
#define CSR_SATP		0x180


#define CSR_IE		CSR_SIE
#define CSR_IP		CSR_SIP
#define CSR_TVEC	CSR_STVEC
#define CSR_SCRATCH	CSR_SSCRATCH
#define CSR_STATUS CSR_SSTATUS
#define CSR_EPC	CSR_SEPC
#define CSR_CAUSE	CSR_SCAUSE
#define CSR_TVAL	CSR_STVAL

#define SR_IE		SR_SIE


#define IRQ_S_TIMER 5
#define IRQ_S_EXT 9

#define MIP_STIP            (1 << IRQ_S_TIMER)

#define SIP_STIP    MIP_STIP /* timer interrupt */


#define RV_IRQ_EXT		IRQ_S_EXT

#define SATP_MODE_39	0x8000000000000000UL
